﻿using DoNet.Bpmn.IRepostitories;
using DoNet.Bpmn.Models;
using DoNet.Core;

namespace DoNet.Bpmn.Repositories
{
    public class BpmnNodePersonnelEmplConfigRepository : BaseRepository<BpmnNodePersonnelEmplConfig>, IBpmnNodePersonnelEmplConfigRepository
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="serviceProvider"></param>
        public BpmnNodePersonnelEmplConfigRepository(IServiceProvider serviceProvider) : base(serviceProvider)
        { }

        #region 同步方法
        /// <summary>
        /// 同步根据BpmnNodePersonneId
        /// </summary>
        /// <param name="bpmnNodePersonneId"></param>
        /// <returns></returns>
        public BpmnNodePersonnelEmplConfig GetByBpmnNodePersonneId(long bpmnNodePersonneId)
        {
            return Db.Queryable<BpmnNodePersonnelEmplConfig>().Where(x => x.BpmnNodePersonneId == bpmnNodePersonneId).First();
        }
        /// <summary>
        /// 同步
        /// </summary>
        /// <param name="bpmnNodePersonneId"></param>
        /// <returns></returns>
        public IEnumerable<BpmnNodePersonnelEmplConfig> GetListByBpmnNodePersonneId(long bpmnNodePersonneId)
        {
            return Db.Queryable<BpmnNodePersonnelEmplConfig>().Where(x => x.BpmnNodePersonneId == bpmnNodePersonneId).Distinct().ToList();
        }
        #endregion 同步方法

        #region 异步方法
        /// <summary>
        /// 异步根据BpmnNodePersonneId
        /// </summary>
        /// <param name="bpmnNodePersonneId"></param>
        /// <returns></returns>
        public async Task<BpmnNodePersonnelEmplConfig> GetByBpmnNodePersonneIdAsync(long bpmnNodePersonneId)
        {
            return await Db.Queryable<BpmnNodePersonnelEmplConfig>().Where(x => x.BpmnNodePersonneId == bpmnNodePersonneId).FirstAsync();
        }
        /// <summary>
        /// 异步
        /// </summary>
        /// <param name="bpmnNodePersonneId"></param>
        /// <returns></returns>
        public async Task<IEnumerable<BpmnNodePersonnelEmplConfig>> GetListByBpmnNodePersonneIdAsync(long bpmnNodePersonneId)
        {
            return await Db.Queryable<BpmnNodePersonnelEmplConfig>().Where(x => x.BpmnNodePersonneId == bpmnNodePersonneId).Distinct().ToListAsync();
        }
        #endregion 异步方法
    }
}
